{if $confirmation}
	<form action="{$GLOBALS.site_url}/payment-page/" method="POST" enctype="multipart/form-data" >
		<input type="hidden" name="action" value="pay_for_products" />
		<input type="hidden" name="price" value="{$price}" />
		<p class="information">[[You have selected the following recurring product(s). Please choose whether you want to buy them (pay once) or subscribe for them (pay every billing period):]]</p>
		{foreach from=$products item=product name=products_block}
			<p><strong>[[{$smarty.foreach.products_block.iteration}]]. {$product.name}</strong></p>
		{/foreach}
        <div class="clr"><br/></div>
		<center><input type="submit" name="buy" value="[[Buy:raw]]"  > &nbsp; <input type="submit" name="subscribe" value="[[Subscribe:raw]]" ></center>
	</form>
{else}
	<h1>[[Shopping Cart]]</h1>
	<div class="clr"><br/></div>
	{if $error == 'user_group'}
		<p class="error">[[You have logged in as {$GLOBALS.current_user.group.caption} but the products you have chosen belong to another User Group. They were automatically deleted from your Shopping Cart]]</p>
	{/if}
	<form action="" method="POST" enctype="multipart/form-data" name="shoppingCartForm">
	<input type="hidden" name="action" value="checkout" />
	<table cellspacing="0" id="shoppingCartTable">
		<thead>
			<tr>
				<th class="tableLeft"> </th>
				<th>[[Item in the cart]]</th>
				<th>[[Qty/Period]]</th>
				<th>[[Price]]</th>
                <th>&nbsp;</th>
				<th class="tableRight"> </th>
			</tr>
		</thead>
		<tbody>
			{foreach from=$products item=product}
				<tr class="{cycle values = 'evenrow,oddrow' advance=true}">
					<td></td>
					<td width="48%" valign="top"><strong>[[{$product.name}]]</strong></td>
					<td width="40%" valign="top">
						{if $product.period}
							{if $product.period_name != 'unlimited'}
								{$product.period} {if $product.period > 1 }[[{$product.period_name|capitalize}s]]{else}[[{$product.period_name|capitalize}]]{/if}
			                {else}
			                	[[Unlimited]]
			                {/if}
						{elseif $product.volume_based_pricing}
							<select name="number_of_listings[{$product.sid}][{$product.item_sid}]" id="number_of_listings_{$product.sid}_{$product.item_sid}" onChange="getPrice(this.value, '{$product.sid}', '{$product.item_sid}')" class="numberOfListings">
								{foreach from=$product.count_listings item=count_listings_info}
									<option value="{$count_listings_info.number_of_listings}" {if $count_listings_info.number_of_listings == $product.number_of_listings} selected="selected" {/if} >[[{$count_listings_info.number_of_listings}]]</option>
								{/foreach}
							</select>
							{foreach from=$product.count_listings item=count_listings_info}
								<input type="hidden" name="price_per_unit_{$product.sid}_{$product.item_sid}_{$count_listings_info.number_of_listings}" id="price_per_unit_{$product.sid}_{$product.item_sid}_{$count_listings_info.number_of_listings}" value="{$count_listings_info.price}" />
							{/foreach}
							<br/>
							[[Expiration period]]:{if $product.expiration_period} {$product.expiration_period} [[Days]]{else}[[Unlimited]]{/if}
						{else}
							{if $product.expiration_period} {$product.expiration_period} [[Days]]{else}[[Unlimited]]{/if}
						{/if}
					</td>
					<td  valign="top" width="10%" id="price_{$product.sid}_{$product.item_sid}">{$GLOBALS.settings.transaction_currency}{$product.price}</td>
                    <td valign="top"><a class="remove" href="#" onClick="location.href = '{$GLOBALS.site_url}/shopping-cart/?action=delete&amp;item_sid={$product.item_sid}'">[[Remove]]</a></td>
					<td></td>
				</tr>
			{/foreach}
            <tr>
                <td colspan="3" id="productTotal"><strong>[[Total]]:</strong></td>
                <td><div id="total_price"> {$GLOBALS.settings.transaction_currency}{$total_price}</div></td>
                <td colspan="2"></td>
            </tr>
		</tbody>
	</table>

    {foreach from=$errors item=caption key=error}
        {if $error eq 'EMPTY_VALUE'}
            <p class="error">'[[{$caption}]]' [[is empty]]</p>
        {elseif $error eq 'NOT_VALID'}
            <p class="error">[[{$caption}]]</p>
        {/if}
    {/foreach}
    {if $applied_products}
        <p class="message">
            [[You have successfully applied the promotion code to the following product(s):]]<br/>
            {foreach from=$applied_products item=applied_product name=applied_product_block}
                [[{$applied_product.name}]]
                {if !$smarty.foreach.applied_product_block.last}
                    ,&nbsp;
                {/if}
            {/foreach}
        </p>
        <p class="information">[[You have received a discount of]] {if $code_info.type == 'percentage'}{$code_info.discount}%{else}{$GLOBALS.settings.transaction_currency}{$code_info.discount}{/if} [[for the above item(s).]]</p>
    {/if}

    {if $GLOBALS.settings.enable_promotion_codes == 1 && $products}
        <div id="promotionCode">
            <strong>[[Promotion code]]:</strong> <input type="text" name="promotion_code" id="inputPromotionCode" value="" />
            <input type="submit" name="applyPromoCode" value="[[Apply:raw]]"  id="applyPromoCode" />
        </div>
    {/if}

	<br/>
	<div style="float: left; width: 50%; text-align: right; padding-right:15px;"><input type="button" name="continue" value="[[Continue Shopping:raw]]" onClick="location.href = '{$GLOBALS.site_url}/products/'" /></div>
	<div><input type="submit" name="submit" value="[[Checkout:raw]]" {if !$GLOBALS.current_user.logged_in}onclick="popUpWindow('{$GLOBALS.site_url}/login/?shopping_cart=checkout&ajaxRelocate=1', 350, 300, '[[Login]]', false, false); return false;"{/if} /></div>
	<div  style="visibility: hidden;"><input type="submit" name="shoppingCartForm" value="[[Checkout:raw]]"  id="shoppingCartForm" /></div>
	<div class="clr"></div>
	</form>
	<script language="javascript" type="text/javascript">
	function getPrice(number_of_listings, product_sid, item_sid)
	{ldelim}
		var price = $("#price_per_unit_"+product_sid+"_"+item_sid+"_"+number_of_listings).val();
		$("#price_"+product_sid+"_"+item_sid).html('{$GLOBALS.settings.transaction_currency}'+price);
		totalPrice();
	{rdelim}
	{literal}
	function totalPrice()
	{
		var totalPrice = {/literal}{$total_price}{literal};
		$("#shoppingCartTable select").each(function(item) {
			var id = $(this).attr('id').replace('number_of_listings_', '');
			var numberOfListings = $(this).val();
			var price = $("#price_per_unit_"+id+"_"+numberOfListings).val()*1;
			if (price < 0)
				price = 0;
			totalPrice += price;
		});
		$("#total_price").html('{/literal}{$GLOBALS.settings.transaction_currency}{literal}'+totalPrice);
	}
	totalPrice();
	{/literal}
	</script>
{/if}